#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int jump(vector<int>& nums) {
        if (nums.size() == 1) return 0;
        int ret = 0, cur = 0;
        int n = nums.size();
        if (nums[0] >= n - 1) return 1;
        for (int left = 0, right = 0; right < n;)
        {
            ret++;
            int ma = 0, tmp = 0;
            for (int i = right + 1; i <= left + nums[left]; i++)
            {
                if (i == n - 1) return ret;
                if (ma < i + nums[i]) tmp = i, ma = i + nums[i];
            }
            right = left + nums[left], left = tmp;
        }
        return ret;
    }
};